﻿using System;
using System.Collections.Generic;
using System.IO;
using Common;
using Domain;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace MapComponentSprite.Global
{
    /// <summary>
    /// 全局资源预加载
    /// </summary>
    public static class Resource
    {

        public static void InitLoad(SpriteBatch spriteBatch, ContentManager content)
        {
           
        }
        /// <summary>
        /// 加载地图单元流
        /// </summary>
        private static void LoadMapUnitSprites()
        {
            
            try
            {
                for (int i = 0; i < MapBackgroundLayerSprite.MapUnitCount; i++)
                {
                    for (int j = 0; j < MapBackgroundLayerSprite.MapUnitCount; j++)
                    {
                        int number = (i + j * MapBackgroundLayerSprite.MapUnitCount);
                        string key = "Map.MapUnit." + number;
                        //Texture2D image = _content.Load<Texture2D>(@"Images\maps\" + number);
                      //  CacheHelper.SetCacheBySliding(key, image, 60 * 60);

                        //using (Stream file = new FileStream(@"Resources/ditu/" + MainMapLayerSprite.Name + "/" + number + ".jpg", FileMode.Open))
                        //{
                        //    try
                        //    {
                        //        Texture2D image = Texture2D.FromStream(SpriteBatch.GraphicsDevice, file);
                        //        MapUnitSprites.Add(number, image);
                        //    }
                        //    catch (Exception)
                        //    {
                        //        MapUnitSprites.Add(number, null);
                        //    }

                        //}
                    }
                }

            }
            catch (Exception e)
            {

            }
        }
    }
}
